<?php
/**
 * AccesspressLite functions and definitions
 *
 * @package AccesspressLite
 */


if ( ! function_exists( 'accesspresslite_setup' ) ) :
/**
 * Sets up theme defaults and registers support for various WordPress features.
 *
 * Note that this function is hooked into the after_setup_theme hook, which
 * runs before the init hook. The init hook is too late for some features, such
 * as indicating support for post thumbnails.
 */
function accesspresslite_setup() {
	/**
	 * Set the content width based on the theme's design and stylesheet.
	 */
	global $content_width;
	/**
	 * Global content width.
	 */
	 if (!isset($content_width))
     	$content_width = 750; /* pixels */

	/*
	 * Make theme available for translation.
	 * Translations can be filed in the /languages/ directory.
	 * If you're building a theme based on AccesspressLite, use a find and replace
	 * to change 'accesspresslite' to the name of your theme in all the template files
	 */
	load_theme_textdomain( 'accesspresslite', get_template_directory() . '/languages' );

	/**
	 * Add callback for custom TinyMCE editor stylesheets. (editor-style.css)
	 * @see http://codex.wordpress.org/Function_Reference/add_editor_style
	 */
	add_editor_style();	

	// Add default posts and comments RSS feed links to head.
	add_theme_support( 'automatic-feed-links' );

	/*
	 * Enable support for Post Thumbnails on posts and pages.
	 *
	 * @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
	 */
	add_theme_support( 'post-thumbnails' );

	add_image_size( 'event-thumbnail', 135, 100, true); //Latest News Events Small Image
	add_image_size( 'featured-thumbnail', 350, 245, true); //Featured Image
	add_image_size( 'portfolio-thumbnail', 400, 450, true); //Portfolio Image		

	// This theme uses wp_nav_menu() in one location.
	register_nav_menus( array(
		'primary' => __( 'Primary Menu', 'accesspresslite' ),
	) );

	// Enable support for Post Formats.
	add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link' ) );

	// Setup the WordPress core custom background feature.
	add_theme_support( 'custom-background', apply_filters( 'accesspresslite_custom_background_args', array(
		'default-color' => 'ffffff',
		'default-image' => '',
	) ) );

}
endif; // accesspresslite_setup
add_action( 'after_setup_theme', 'accesspresslite_setup' );

/**
 * Implement the Theme Option feature.
 */
require get_template_directory() . '/inc/custom-header.php';

/**
 * Implement the Theme Option feature.
 */
require get_template_directory() . '/inc/admin-panel/theme-options.php';

/**
 * Custom template tags for this theme.
 */
require get_template_directory() . '/inc/template-tags.php';

/**
 * Custom functions that act independently of the theme templates.
 */
require get_template_directory() . '/inc/extras.php';

/**
 * Load Jetpack compatibility file.
 */
require get_template_directory() . '/inc/jetpack.php';

/**
 * Implement the custom metabox feature
 */
require get_template_directory() . '/inc/custom-metabox.php';


    //Login Page
    function custom_login() {
        echo '<link rel="stylesheet" type="text/css" href="' . get_bloginfo('template_directory') . '/css/login.css" />'."\n";
        echo '<script type="text/javascript" src="'.get_bloginfo('template_directory').'/js/jquery.min.js"></script>'."\n";
    }
    add_action('login_head', 'custom_login');

    //Login Page Title
    function custom_headertitle ( $title ) {
        return get_bloginfo('name');
    }
    add_filter('login_headertitle','custom_headertitle');

    //Login Page Link
    function custom_loginlogo_url($url) {
        return esc_url( home_url('/') );
    }
    add_filter( 'login_headerurl', 'custom_loginlogo_url' );

    //Login Page Footer
    function custom_html() {
        echo '<div class="footer">'."\n";
        echo '<p>Copyright &copy; '.date('Y').' All Rights Reserved</p>'."\n";
        echo '</div>'."\n";
        echo '<script type="text/javascript" src="'.get_bloginfo('template_directory').'/js/resizeBg.js"></script>'."\n";
        echo '<script type="text/javascript">'."\n";
        echo 'jQuery("body").prepend("<div class=\"loading\"><img src=\"'.get_bloginfo('template_directory').'/css/images/login_loading.gif\" width=\"58\" height=\"10\"></div><div id=\"bg\"><img /></div>");'."\n";
        echo 'jQuery(\'#bg\').children(\'img\').attr(\'src\', \''.get_bloginfo('template_directory').'/css/images/login_bg.jpg\').load(function(){'."\n";
        echo '  resizeImage(\'bg\');'."\n";
        echo '  jQuery(window).bind("resize", function() { resizeImage(\'bg\'); });'."\n";
        echo '  jQuery(\'.loading\').fadeOut();'."\n";
        echo '});';
        echo '</script>'."\n";
    }
    add_action('login_footer', 'custom_html');

    /*精简后台代码*/
    function disable_dashboard_widgets() {   
        remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');//近期评论 
        remove_meta_box('dashboard_recent_drafts', 'dashboard', 'normal');//近期草稿
        remove_meta_box('dashboard_primary', 'dashboard', 'core');//wordpress博客  
        remove_meta_box('dashboard_secondary', 'dashboard', 'core');//wordpress其它新闻  
        remove_meta_box('dashboard_right_now', 'dashboard', 'core');//wordpress概况  
        remove_meta_box('dashboard_incoming_links', 'dashboard', 'core');//wordresss链入链接  
        remove_meta_box('dashboard_plugins', 'dashboard', 'core');//wordpress链入插件  
        remove_meta_box('dashboard_quick_press', 'dashboard', 'core');//wordpress快速发布   
    }  
    add_action('admin_menu', 'disable_dashboard_widgets');

    // 隐藏所有更新提示(比如插件、主题等更新)
    add_action('admin_menu','hide_admin_notices');
        function hide_admin_notices() {
            remove_action( 'admin_notices', 'update_nag', 3 );
    }

    // 移除仪表盘左侧“更新”这个子栏目
    add_action('admin_menu', 'remove_menus', 102);
        function remove_menus() {
            global $submenu;
            remove_submenu_page ( 'index.php', 'update-core.php' );
    }

    //  屏蔽后台页脚版本号
    function change_footer_admin () {return '';}
    add_filter('admin_footer_text', 'change_footer_admin', 9999);
    function change_footer_version() {return '';}
    add_filter( 'update_footer', 'change_footer_version', 9999);

    //屏蔽 WP 后台“显示选项”和“帮助”选项卡
    function remove_screen_options(){ return false;}
        add_filter('screen_options_show_screen', 'remove_screen_options');
     
        add_filter( 'contextual_help', 'wpse50723_remove_help', 999, 3 );
     
        function wpse50723_remove_help($old_help, $screen_id, $screen){
        $screen->remove_help_tabs();
        return $old_help;
    }


    //屏蔽后台导航栏LOGO、更新、评论

    function annointed_admin_bar_remove() {
            global $wp_admin_bar;
            /* Remove their stuff */
            $wp_admin_bar->remove_menu('wp-logo');
            $wp_admin_bar->remove_menu('updates'); //插件更新信息
            $wp_admin_bar->remove_menu('comments');  //评论
    }
    add_action('wp_before_admin_bar_render', 'annointed_admin_bar_remove', 0);